home *** CD-ROM | disk | FTP | other *** search
/ Trading on the Edge / Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin / pc / mac_file / vendor_d / neuralwa / nw2v50 / noiseio.c < prev    next >
Text File  |  1993-08-23  |  20KB  |  792 lines

  1. /* noiseio.c */
  2. /************************************************************************
  3.  * Copyright(C) 1987-1992 NeuralWare Inc                                *
  4.  * Penn Center West, IV-227, Pittsburgh, PA 15276                       *
  5.  * Telephone: (412) 787-8222    FAX: (412) 787-8220                     *
  6.  *                                                                      *
  7.  * All rights reserved.  No part of this program may be reproduced,     *
  8.  * stored in a retrieval system, or transmitted, in any form or by any  *
  9.  * means, electronic, mechanical, photocopying, recording or otherwise  *
  10.  * without the prior written permission of the copyright owner,         *
  11.  * NeuralWare, Inc.                                                     *
  12.  *                                                                      *
  13.  *                          PROPRIETARY NOTICE                          *
  14.  *                                                                      *
  15.  * This document is the property of NeuralWare, Inc. and contains       *
  16.  * trade-secrets and other proprietary information.  The information    *
  17.  * herein is reserved as proprietary to NeuralWare, and is not to be    *
  18.  * published, reproduced, copied, disclosed, used, or reverse           *
  19.  * engineered without the express written consent of a duly authorized  *
  20.  * representative of NeuralWare.                                        *
  21.  ************************************************************************
  22.  */
  23.  
  24. /*******************************************************************/
  25. /*                                                                 */
  26. /*    noiseio.c -  Sample User IO Program                          */
  27. /*                                                                 */
  28. /*    Author: John C. Fairman           August 31, 1990            */
  29. /*    Copyright 1990 by NeuralWare Inc.                            */
  30. /*                                                                 */
  31. /*    $Author   :  $                                               */
  32. /*    $Date     :  $                                               */
  33. /*    $Source   :  $                                               */
  34. /*    $Revision :  $                                               */
  35. /*    $Log      :  $                                               */
  36. /*                                                                 */
  37. /*******************************************************************/
  38.  
  39. #define UIO_SERVER             1
  40. #define SERVER_EMULATOR_FILE   1
  41. #define SKIP_COMPAT_DATA       1
  42. #include "userutl.h"
  43.  
  44. #include <math.h>
  45. #include <string.h>
  46.  
  47. #ifndef SUN
  48. #ifndef DLC
  49. #include <stdlib.h>
  50. #endif
  51. #endif
  52.  
  53. #include "uio_strc.h"
  54. #include "uio_tran.h"
  55. #include "uio_reqs.pro"
  56. #include "uio_cmds.pro"
  57.  
  58. #ifdef MAC
  59. #include "macuio.redef"
  60. #endif
  61.  
  62. #ifdef MAC
  63. #define LINE_COLOR 15
  64. #undef FASTRAND
  65. #else
  66. #define LINE_COLOR 13
  67. #define FASTRAND
  68. #endif
  69.  
  70. int ReadTS ARGLIST(( char * ));
  71.  
  72. /************************************************************************
  73.  *
  74.  *  Noise Filtering Example: Input / Output Routine
  75.  *
  76.  ************************************************************************
  77.    This routine reads a set of data values from an input file.  It assumes
  78.    that there is one measurement per input line.  The data has been
  79.    pre-scaled using "conv".
  80.  
  81.    During training, a block of 29 inputs is randomly selected from the
  82.    entire time-series.  This is applied as both the input and the output
  83.    for the network.  The network is treated as an "auto-associative"
  84.    network.
  85.  
  86.    During recall, the time-series is stepped through sequentially.  Only
  87.    the middle processing element of the output layer is plotted on the 
  88.    graph.
  89.  */
  90.  
  91. /*   */
  92. /************************************************************************
  93.  *
  94.  *  Window management
  95.  *
  96.  ************************************************************************
  97.  */
  98.  
  99. #define inTrain         3       /* training window inner border */
  100. #define inWMSE          4       /* mean square error inner border */
  101.  
  102. /************************************************************************
  103.  *
  104.  *  Learning Error display
  105.  *
  106.  ************************************************************************
  107.  */
  108.  
  109. #define ENPts   491 /* # of error points */
  110. #define EYVals    90  /* # of y-values */
  111. int EX0   = 0;          /* x-coord of lower left corner */
  112. int EY0   = 0;    /* y-coord of lower left corner */
  113. int ECtr    = 0;    /* current "data" item */
  114. double  EXScale   = 0.0;  /* x-scale factor */
  115. double  EXOffset  = 0.0;  /* error offset */
  116. float EVals[ENPts]  = {0};    /* error values */
  117. int EVFlag[ENPts] = {0};    /* error value valid flag */
  118. int *null_ptr = 0;    /* null pointer for uSoft 5.0 */
  119.  
  120. void ShowError()      /* plot out the error array */
  121. {
  122.   int   n;  /* index into the data array */
  123.   int   dx; /* draw index */
  124.   int   pdx;  /* previous draw index */
  125.  
  126.   /* put up a header */
  127.     
  128.  
  129.   /* plot the data */
  130.   pdx = 0;
  131.   for( n = 0; n < ENPts; n++ ) {
  132.     if ( EVFlag[n] == 0 ) {
  133.       pdx = 0;
  134.       continue;
  135.     }
  136.     dx = EXScale * (EVals[n] - EXOffset);
  137.  
  138.     if ( dx >= EYVals ) dx = EYVals - 1;
  139.     if ( dx <  0    ) dx = 0;
  140.     if ( n == 0 || pdx == 0 || pdx == dx )
  141.       ug_point( inWMSE, LINE_COLOR, 0, EX0+n, EY0+dx );
  142.     else ug_line(  inWMSE, LINE_COLOR, 0, EX0+n, EY0+pdx, EX0+n, EY0+dx, 0 );
  143.     pdx = dx;
  144.   }
  145.   /* show where next data point goes */
  146.   ug_line( inWMSE, 15, 0, EX0+ECtr, EY0+1, EX0+ECtr, EY0+EYVals, 0 );
  147. }
  148. void NextError( v )     /* plot the next error datum */
  149. double    v;    /* value of error to plot */
  150. {
  151.   int   dx;   /* y-coordinate (relative) of error */
  152.   int   pdx;    /* previous y-coord */
  153.   double  pv;   /* previous v */
  154.  
  155.   /* save the item for posterity */
  156.   EVals[ECtr]   = v;
  157.   EVFlag[ECtr]  = 1;
  158.  
  159.   /* compute where the point should be plotted */
  160.   dx = (v - EXOffset) * EXScale;
  161.   if ( dx < 1       )   dx = 1;
  162.   if ( dx >= EYVals )   dx = EYVals - 1;
  163.   
  164.   /* clear old cursor out */
  165.   ug_line( inWMSE,  0, 0, EX0+ECtr, EY0, EX0+ECtr, EY0+EYVals, 0 );
  166.  
  167.   /* plot new data point */
  168.   if ( ECtr != 0 && EVFlag[ECtr-1] != 0 ) {
  169.     pv  = EVals[ECtr-1];
  170.     pdx = (pv - EXOffset) * EXScale;
  171.     if ( pdx < 0 )    pdx = 0;
  172.     if ( pdx > EYVals-1 ) pdx = EYVals-1;
  173.   } else  pdx = 0;
  174.   if ( ECtr == 0 || EVFlag[ECtr-1] == 0 )
  175.     ug_point( inWMSE, LINE_COLOR, 0, EX0+ECtr, EY0+dx );
  176.   else ug_line( inWMSE, LINE_COLOR, 0, EX0+ECtr, EY0+pdx, EX0+ECtr, EY0+dx, 0 );
  177.   /* compute next cursor location */
  178.   ECtr++;
  179.   if ( ECtr >= ENPts ) ECtr = 0;
  180.  
  181.   /* draw new cursor line */
  182.   ug_line( inWMSE, 15, 0, EX0+ECtr, EY0, EX0+ECtr, EY0+EYVals, 0 );
  183.   
  184. }
  185. /*   */
  186. /************************************************************************
  187.  *
  188.  *  Common data & statics
  189.  *
  190.  ************************************************************************
  191.  */
  192.  
  193. /* data set definitions */
  194.  
  195. #define NTPTS     491               /* number of pts in data file */
  196. #define SetSize   450               /* size of training set */
  197. float   TrainSet[NTPTS+1] = {0.0};  /* current training set */
  198. float TrainRef[NTPTS+1] = {0.0};  /* reference training data */
  199. int SampX[NTPTS+1]    = {0};    /* sample array */
  200. int SX      = -1;   /* index into sample array */
  201. int InputLen= 0;        /* input length */
  202. int     TSetL   = 0;              /* training set length */
  203. int TrainSz = 30;       /* training samples per pass */
  204. int ToTrain = 0;        /* # of items still to train */
  205. long  Pass  = 0;        /* pass number */
  206. int DataCtr = 0;        /* data counter */
  207. int NextFlag= 0;        /* next cycle flag */
  208. float LastDR  = 0.0;      /* last desired result */
  209. float MSE = 0.0;      /* mean square error for a data set */
  210. int     x       = 0;              /* previous x-coordinate */
  211. int     ynew    = 0;              /* current y-coordinate */
  212. int     yold    = 0;              /* previous y-coordinate */
  213. int     yout    = 0;              /* network out y-coordinate */
  214. int     xlag    = 14;             /* first x-coordinate for network out */
  215. /* window position and sizes */
  216. #define XBorder 3
  217. #define YBorder 3
  218. #define InTX0 70
  219. #define InTY0 10
  220. #define InTX1 (InTX0+SetSize+1)
  221. #define InTY1 (InTY0+EYVals)
  222.  
  223. #define InMX0 (InTX0)
  224. #define InMY0 (InTY1+3*YBorder)
  225. #define InMX1 (InMX0+SetSize+1)
  226. #define InMY1 (InMY0+EYVals)
  227.  
  228. /*   */
  229. /************************************************************************
  230.  *
  231.  *  Plot the training set
  232.  *
  233.  ************************************************************************
  234.  */
  235.         
  236. PlotTrain()
  237. {
  238.   int x;
  239.   int wx;
  240.   int yold, ynew;
  241.  
  242.   yold = 0;
  243.   x    = 0;
  244.   for (wx = 0; wx < TSetL; wx++) {
  245.     /* plot the values in the Training Set */
  246.     ynew = TrainSet[wx] * EYVals;
  247.     if ( x == 0 )
  248.       ug_point( inTrain, 13, 0, x, ynew );
  249.     else  ug_line (inTrain, 13, 0, x, yold, x, ynew, 0);
  250.     x++;
  251.     yold = ynew;
  252.   }
  253. }
  254. /*   */
  255. /************************************************************************
  256.  *
  257.  *  Training Set Input / Check it is there Routines
  258.  *
  259.  ************************************************************************
  260.  */
  261.  
  262. int IsTSOk()
  263. {
  264.   if ( TSetL <= 0 ) return( UIO_ERROR );
  265.   else return( UIO_OK );
  266. }
  267.  
  268. int ReadTS( buf )
  269. char    *buf;   /* work buffer */
  270. {
  271.   FILE  *fp;    /* input file pointer */
  272.   char  *sp;    /* input string */
  273.   int  c;   /* work character */
  274.   int  wx;    /* work index */
  275.  
  276.   SX = -1;
  277.   TSetL = 0;
  278.   for(;;) {
  279.     PutStr ("What is the training input File (<RETURN> for default) ?");
  280.     sp = GetStr();
  281.     while( *sp && *sp <= ' ' ) sp++;  /* skip leading white space */
  282.     if ( *sp == '\0' ) {
  283.       sp = "noisetst.1";      /* default file name */
  284.     }
  285.     
  286.     fp = fopen (sp, "r");    
  287.     if (fp == (FILE *)null_ptr ) {
  288.       sprintf( buf, "Could not open <%s>\n", sp );
  289.       PutStr( buf );
  290.       continue;
  291.     }
  292.  
  293.     for ( wx = 0; wx < NTPTS;)   {
  294.       if ( fgets( &buf[0], 80, fp ) == 0 ) break;
  295.       /* kill any comments */
  296.       
  297.       for( sp = &buf[0]; (c = *sp) != '\0'; sp++ ) {
  298.   if ( c == '!' || c == '*' || c == '\r' || c == '\n' )
  299.     break;
  300.       }
  301.       *sp = '\0';     /* kill comments, etc */
  302.  
  303.       /* skip leading space and check for blank lines */
  304.       
  305.       for( sp = &buf[0]; *sp && *sp <= ' '; ) sp++;
  306.       if ( *sp == '\0' )
  307.    continue;
  308.       sscanf( buf, "%f", &TrainSet[wx] );
  309.       TrainRef[wx] = TrainSet[wx];
  310.       wx++;
  311.     }
  312.     TSetL = wx;
  313.     fclose(fp);   
  314.  
  315.     if ( TSetL == 0 ) {
  316.       PutStr( "Nothing in data set, try again\n" );
  317.       continue;
  318.     }
  319.     
  320.     break;
  321.   }
  322.  
  323.   return( 0 );
  324. }
  325. /*   */
  326.  
  327. static int ModeFlag = 0;  /* 0=do not write to file; 1=write to file */
  328. static int InitFlag = 0;
  329. FILE  *OutFp      = 0;  /* output file pointer */
  330. #if ((SUN || VAXULT) && !SYSV) || IRIS
  331.     extern long  random();
  332. #define rand   random
  333. #define MAXRAND (0x7fffffffl)
  334. #else
  335.     extern int   rand();  /* random number generator */
  336. #ifdef VMS
  337. #define MAXRAND (0x7fffffffl)
  338. #else
  339. #define MAXRAND (0x7fff)
  340. #endif
  341. #endif
  342.  
  343. OpenAllWindows( )
  344. {
  345.   ug_window( inTrain, 0,  InTX0, InTY0, InTX1, InTY1 );
  346.   ug_window( inWMSE,  0,  InMX0, InMY0, InMX1, InMY1 );
  347.   
  348.   InitFlag = 1;
  349. }
  350.  
  351. /*******************************************************************/
  352. /*                                                                 */
  353. /* Functions necessary for handling the User I/O package itself.   */
  354. /*                                                                 */
  355. /*******************************************************************/
  356.  
  357. /* FUNCTION */
  358. NINT UIO_Init(file)
  359. TEXT *file;
  360. {
  361.   OpenAllWindows( );
  362. }
  363.  
  364.  
  365. /* */
  366. /* FUNCTION */
  367. NINT UIO_Term(process)
  368. NINT process;
  369. {
  370.   if ( OutFp != (FILE *)null_ptr ) fclose( OutFp );
  371.  
  372.   PutStr( "bye bye\n" );
  373.  
  374.   return(UIO_OK);
  375. }
  376.  
  377. /* FUNCTION */
  378. NINT UIO_Attention()
  379. {
  380.   TEXT *sp;
  381.  
  382.   InitFlag = 0;
  383.  
  384.   if ( OutFp != (FILE *)null_ptr ) fclose( OutFp );
  385.   OutFp = (FILE *)0;
  386.   PutStr( "File to write to or <RETURN> for none? " );
  387.   sp = GetStr();
  388.   if ( *sp > ' ' ) {
  389.     OutFp = fopen( sp, "w" );   /* just write */
  390.     if ( OutFp == (FILE *)null_ptr )
  391.       PutStr( "Could not open output file\n" );
  392.   }
  393.   OpenAllWindows( );
  394.  
  395.   return(UIO_OK);
  396. }
  397.  
  398.  
  399. /*******************************************************************/
  400. /*                                                                 */
  401. /*  Functions necessary for handling a learning session.           */
  402. /*                                                                 */
  403. /*******************************************************************/
  404.  
  405. /* FUNCTION */
  406. NINT UIO_Learn_Start()
  407. {
  408.   TEXT  *sp;    /* string pointer */
  409.   float  v;   /* work float */
  410.   TEXT buf[100];  /* work buffer */
  411.   NINT wx;    /* work index  */
  412.  
  413.   if (!InitFlag) OpenAllWindows( );
  414.  
  415.   if ( TSetL <= 0 )
  416.     ReadTS( &buf[0] );      /* read training data */
  417.  
  418.   if ( IsTSOk() ) return(UIO_ERROR);  /* exit if error */
  419.  
  420.   /* set up the window & tell the user what to do */
  421.   ug_winclr( 0 );       /* clear windows */
  422.  
  423.   ug_puts( inWMSE,  7, 0, XBorder,YBorder, "Mean Square Error", 0 );
  424.   ug_puts( inTrain, 7, 0, XBorder,YBorder, "Raw Input Data", 0 );
  425.  
  426.   for( wx = 0; wx < NTPTS; wx++ ) TrainSet[wx] = TrainRef[wx];
  427.  
  428.   PlotTrain();
  429.   ToTrain = TrainSz-1;
  430.  
  431.   /* ask the user for the scale factor for errors */
  432.   PutStr( "What is the maximum expected error? " );
  433.   sp = GetStr();
  434.  
  435.   v = 0.0;
  436.   sscanf( sp, "%f", &v );
  437.   if ( v < 0.0001 ) {
  438.     if ( EXScale < .0001 )
  439.       EXScale = EYVals / 2.0;
  440.   } else {
  441.     EXScale = EYVals / v;
  442.   }
  443.  
  444.   /* display the errors as they stand */
  445.   ShowError();
  446.  
  447.   DataCtr = 0;
  448.   MSE   = 0.0;
  449.   Pass    = 0;
  450.  
  451.   return(UIO_OK);
  452. }
  453.  
  454.  
  455. /* */
  456. /* FUNCTION */
  457. NINT UIO_Learn_Input(LayN, nPEs, Datap)
  458. NINT  LayN;
  459. NINT  nPEs;
  460. SREAL *Datap;
  461. {
  462.   NINT   wx;    /* work index  */
  463.   int  wn;    /* work number */
  464.   int  ModVal;  /* modulo value */
  465.  
  466.   if (!InitFlag) OpenAllWindows( );
  467.  
  468.   if ( IsTSOk() ) return(UIO_ERROR);  /* exit on error */
  469.  
  470.   if ( nPEs > InputLen )  InputLen = nPEs;
  471.  
  472.   /* zero out the input vector */
  473.   for( wx = 0; wx < nPEs; wx++ ) Datap[wx] = 0.0;
  474.  
  475. #ifdef FASTRAND
  476. /* added int cast for MS-C 7.0; 4-28-93 mjs */
  477. #ifdef MSC
  478.   wn = abs( (int)(((long)rand()) % (TSetL - nPEs)) );
  479. #else
  480.   wn = abs( ((long)rand()) % (TSetL - nPEs) );
  481. #endif
  482. #else
  483.   /* pick next training input randomly */
  484.   ModVal = TSetL - nPEs;
  485.   if ( SX < 0 || SX >= ModVal ) {
  486.     for( SX = 0; SX < ModVal; SX++ ) {
  487.     RandAgain:
  488.       wn = rand() % ModVal;
  489.       for( wx = 0; wx < SX; wx++ ) {
  490.   if ( wn == SampX[wx] ) goto RandAgain;
  491.       }
  492.       SampX[SX] = wn;
  493.     }
  494.     SX = 0;
  495.   }
  496.   wn = SampX[SX++];
  497. #endif
  498.  
  499.   for (wx = 0; wx < nPEs; wx++, wn++)
  500.     Datap[wx] = TrainSet[wn];
  501.   
  502.   /*desired response*/
  503.   LastDR = Datap[nPEs/2];
  504.   
  505.   return(UIO_OK);
  506. }
  507.  
  508.  
  509. /* FUNCTION */
  510. NINT UIO_Learn_Output(LayN, nPEs, Datap)
  511. NINT  LayN;
  512. NINT  nPEs;
  513. SREAL *Datap;
  514. {
  515.   NINT   wx;    /* work index  */
  516.  
  517.   if (!InitFlag) OpenAllWindows( );
  518.  
  519.   wx = 0;
  520.   Datap[wx++] = LastDR;     /* set data */
  521.  
  522.   while( wx < nPEs ) Datap[wx++] = 0.0; /* no data for these */
  523.  
  524.   return(UIO_OK);
  525. }
  526.  
  527.  
  528. /* */
  529. /* FUNCTION */
  530. NINT UIO_Learn_Result(LayN, nPEs, Datap)
  531. NINT  LayN;
  532. NINT  nPEs;
  533. SREAL *Datap;
  534. {
  535.   float  v;   /* work float */
  536.   TEXT   buf[100];  /* work buffer */
  537.  
  538.   if (!InitFlag) OpenAllWindows( );
  539.  
  540.   v = Datap[nPEs/2] - LastDR;   /* error */
  541.   MSE += (v * v);       /* mean square error */
  542.  
  543.   if ( --ToTrain <= 0 ) {
  544.     MSE = sqrt(MSE)/TrainSz;
  545.     Pass++;
  546.  
  547.     sprintf( buf, "pass = %ld, MSE = %.3f\n", Pass, MSE );
  548.     PutStr( buf );
  549.     NextError( MSE );
  550.     MSE = 0.0;
  551.     ToTrain = TrainSz;
  552.   }
  553.  
  554.   return(UIO_OK);
  555. }
  556.  
  557.  
  558. /* FUNCTION */
  559. NINT UIO_Learn_End()
  560. {
  561.   NINT ret_val = UIO_OK;
  562.  
  563.  
  564.   /* USER TO PLACE CODE HERE */
  565.  
  566.   return(ret_val);
  567. }
  568.  
  569.  
  570. /* */
  571. /*******************************************************************/
  572. /*                                                                 */
  573. /*  Functions necessary for handling a recall or testing session.  */
  574. /*                                                                 */
  575. /*******************************************************************/
  576.  
  577. /* FUNCTION */
  578. NINT UIO_Recall_Start()
  579. {
  580.   char  *sp;    /* string pointer */
  581.   float  v;   /* work float */
  582.   TEXT buf[100];  /* work buffer */
  583.   NINT wx;    /* work index  */
  584.  
  585.   if (!InitFlag) OpenAllWindows( );
  586.  
  587.   ReadTS( &buf[0] );      /* read new test data */
  588.  
  589.   if ( IsTSOk() ) return(UIO_ERROR);  /* no good */
  590.  
  591.   PutStr( "How Much Noise (0-100%)? " );
  592.   sp = GetStr();
  593.   if ( *sp == 0 ) v = 0.0;
  594.   else  sscanf( sp, "%f", &v );
  595.  
  596.   v = .01 * v;
  597.   for( wx = 0; wx < NTPTS; wx++ )
  598.     TrainSet[wx] = TrainRef[wx] + (v * (((2.0*rand())/MAXRAND)-1.));
  599.  
  600.   DataCtr = 0;
  601.  
  602.   ug_winclr( 0 );
  603.   PlotTrain();
  604.   ug_puts( inWMSE,  7, 0, XBorder,YBorder, "Filtered Output Signal", 0 );
  605.   ug_puts( inTrain, 7, 0, XBorder,YBorder, "Noisy Input Signal", 0 );
  606.  
  607.   yold = 0;
  608.   xlag = 0;
  609.  
  610.   return(UIO_OK);
  611. }
  612.  
  613.  
  614. /* FUNCTION */
  615. NINT UIO_Read(LayN, nPEs, Datap)
  616. NINT  LayN;
  617. NINT  nPEs;
  618. SREAL *Datap;
  619. {
  620.   NINT   wx;    /* work index  */
  621.  
  622.   if (!InitFlag) OpenAllWindows( );
  623.  
  624.   if ( IsTSOk() ) return(UIO_ERROR);    /* exit on error */
  625.  
  626.   if ( nPEs > InputLen )  InputLen = nPEs;
  627.   if ( xlag == 0 )    xlag = InputLen / 2;
  628.  
  629.   /* zero out the input vector */
  630.   for (wx = 0; wx < nPEs; wx++) Datap[wx] = 0.0;
  631.         
  632.   /* select the next string from the data set */
  633.   for (wx = 0; wx < nPEs; wx++) 
  634.     Datap[wx] = TrainSet[wx + DataCtr];     
  635.  
  636.   LastDR = Datap[nPEs/2];
  637.  
  638.   return(UIO_OK);
  639. }
  640.  
  641.  
  642. /* */
  643. /* FUNCTION */
  644. NINT UIO_Write(LayN, nPEs, Datap)
  645. NINT  LayN;
  646. NINT  nPEs;
  647. SREAL *Datap;
  648. {
  649.   int    wx;    /* work index */
  650.   NINT ret_val = UIO_OK;
  651.  
  652.   if (!InitFlag) OpenAllWindows( );
  653.  
  654.   if ( OutFp != (FILE *)null_ptr )
  655.     fprintf( OutFp, "%.5f%s", Datap[nPEs/2], NEW_LINE_STR );
  656.  
  657.   yout = Datap[nPEs/2] * EYVals;
  658.   if ( yout >= EYVals ) yout = EYVals - 1;
  659.   if ( yout <  0      ) yout = 0;
  660.   if (DataCtr == 0) 
  661.     ug_point(inWMSE,LINE_COLOR,0,xlag,yout);
  662.   else  ug_line( inWMSE,LINE_COLOR,0,xlag,yold,xlag,yout, 0);
  663. #if 0
  664.   wx = LastDR * EYVals;
  665.   if ( wx >= EYVals ) wx = EYVals - 1;
  666.   if ( wx <  0      ) wx = 0;
  667.   ug_point( inWMSE, 6,0,xlag,wx);
  668. #endif
  669.   xlag++;
  670.   yold = yout;
  671.   DataCtr++;
  672.   
  673.   if(DataCtr >= (TSetL - InputLen * 2)) {
  674.     DataCtr = 0;
  675.     ret_val = UIO_ERROR;
  676.     if ( OutFp != (FILE *)null_ptr ) {
  677.       fclose( OutFp );
  678.       OutFp = (FILE *)0;
  679.     }
  680.     PutStr("Hit <RETURN> to continue");
  681.     GetStr();
  682.   }
  683.  
  684.   return(ret_val);
  685. }
  686.  
  687. /* FUNCTION */
  688. NINT UIO_Write_Step(LayN, nPEs, Datap)
  689. NINT  LayN;
  690. NINT  nPEs;
  691. SREAL *Datap;
  692. {
  693.   NINT ret_val = UIO_OK;
  694.  
  695.  
  696.   /* USER TO PLACE CODE HERE */
  697.  
  698.   return(ret_val);
  699. }
  700.  
  701.  
  702. /* */
  703. /* FUNCTION */
  704. NINT UIO_Recall_Test(LayN, nPEs, Datap)
  705. NINT  LayN;
  706. NINT  nPEs;
  707. SREAL *Datap;
  708. {
  709.   NINT   wx;    /* work index  */
  710.  
  711.   if (!InitFlag) OpenAllWindows( );
  712.  
  713.   wx = 0;
  714.   Datap[wx++] = LastDR;     /* set data */
  715.  
  716.   while( wx < nPEs ) Datap[wx++] = 0.0; /* no data for these */
  717.  
  718.   return(UIO_OK);
  719. }
  720.  
  721. /* FUNCTION */
  722. NINT UIO_Recall_End()
  723. {
  724.   NINT ret_val = UIO_OK;
  725.  
  726.  
  727.   /* USER TO PLACE CODE HERE */
  728.  
  729.   return(ret_val);
  730. }
  731.  
  732.  
  733. /* */
  734. /*******************************************************************/
  735. /*                                                                 */
  736. /*  Other miscelaneous functions.                                  */
  737. /*                                                                 */
  738. /*******************************************************************/
  739.  
  740. /* FUNCTION */
  741. NINT UIO_Instrument(Instrument_id, nDataElems, DataElemp)
  742. NINT  Instrument_id;
  743. NINT  nDataElems;
  744. SREAL *DataElemp;
  745. {
  746.   NINT ret_val = UIO_OK;
  747.   
  748.  
  749.   /* USER TO PLACE CODE HERE */
  750.  
  751.   return(ret_val);
  752. }
  753.  
  754. /* FUNCTION */
  755. NINT UIO_ObjFunc(eoeflag, DataElemp)
  756. NINT  eoeflag;
  757. SREAL *DataElemp;
  758. {
  759.   NINT ret_val = UIO_OK;
  760.  
  761.   /* USER TO PLACE CODE HERE */
  762.  
  763.   return(ret_val);
  764. }
  765.  
  766. /* FUNCTION */
  767. NINT UIO_Rewind()
  768. {
  769.   NINT ret_val = UIO_OK;
  770.  
  771.  
  772.   /* USER TO PLACE CODE HERE */
  773.  
  774.   return(ret_val);
  775. }
  776.  
  777.  
  778. /* */
  779. /* FUNCTION */
  780. NINT UIO_Explain(LayN, nPEs, Datap)
  781. NINT  LayN;
  782. NINT  nPEs;
  783. SREAL *Datap;
  784. {
  785.   NINT ret_val = UIO_OK;
  786.  
  787.  
  788.   /* USER TO PLACE CODE HERE */
  789.  
  790.   return(ret_val);
  791. }
  792.